package com.course.android.activity;

import android.content.Intent;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.course.android.R;
import com.course.android.activity.base.BaseActivity;
import com.course.android.ui.adapter.MainPageAdapter;
import com.course.utils.web.OkHttpUtils;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends BaseActivity {
    ListView lv;
    MainPageAdapter mainPageAdapter;
    List<String> menus = new ArrayList<>();


    @Override
    protected void initView() {
        lv = findViewById(R.id.lv);
        mainPageAdapter = new MainPageAdapter(this);
        lv.setAdapter(mainPageAdapter);
        lv.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    ActivityIntent.toLifeCycle(newIntentLauncher(), MainActivity.this);
                }
                if (position == 1) {
                    ActivityIntent.toIntent(newIntentLauncher(), MainActivity.this);
                }
                if (position == 2) {
                    ActivityIntent.toConstraintIntent(newIntentLauncher(), MainActivity.this);
                }
                if (position == 3) {
                    ActivityIntent.toLinearlayoutIntent(newIntentLauncher(), MainActivity.this);
                }
                if (position == 4) {
                    ActivityIntent.toViewIntent(newIntentLauncher(), MainActivity.this);
                }
//                if (position == 5) {
//                    ActivityIntent.toWebViewIntent(newIntentLauncher(), MainActivity.this);
//                }
//                if (position == 6) {
//                    ActivityIntent.toWebViewIntent(newIntentLauncher(), MainActivity.this);
//                }
                if (position == 7) {
                    ActivityIntent.toHttpViewIntent(newIntentLauncher(), MainActivity.this);
                }
                if (position == 8) {
                    ActivityIntent.toBluetoothViewIntent(newIntentLauncher(), MainActivity.this);
                }
                if (position == 9) {
                    ActivityIntent.toGpsViewIntent(newIntentLauncher(), MainActivity.this);
                }
            }
        });
//        OkHttpUtils.post();
    }

    @Override
    protected void initData() {

        menus.add("activity 生命周期");
        menus.add("activity 页面跳转");
        menus.add("layout   相对布局");
        menus.add("layout   线性布局");
        menus.add("view     常用控件");
        menus.add("view     webview");
        menus.add("view     列表展示");
        menus.add("view     网络请求");
        menus.add("view     蓝牙测试");
        menus.add("view     GPS测试");
        mainPageAdapter.setRes(menus);
    }

    @Override
    protected int bindLayout() {
        return R.layout.activity_main;
    }

    @Override
    protected void onActivityResultCallBack(Integer reqCode, Intent data) {

    }
}
